//
//  BVRootTool.m
//  BuyVegetable
//
//  Created by yushanchang on 16/11/7.
//  Copyright © 2016年 com.yinding. All rights reserved.
//

#import "BVRootManager.h"
#import "BVTabBarController.h"
#import "BVNewFeatureViewController.h"

#define Version @"version"

@implementation BVRootManager

+ (void)chooseRootViewController:(UIWindow *)window {
    
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:Version];
    
    if ([currentVersion isEqualToString:lastVersion]) {
        BVTabBarController *tabBarVC = [[BVTabBarController alloc] init];
        window.rootViewController = tabBarVC;
        
    } else {
        
        BVNewFeatureViewController *newFeatureVC = [[BVNewFeatureViewController alloc] init];
        window.rootViewController = newFeatureVC;
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:Version];
    }

}

@end
